package jk.wrapper.filters;

import java.util.List;

import jk.wrapper.common.util.StringUtil;

import org.apache.commons.lang.BooleanUtils;

public class HtmlTagFilter extends AbstractNodeFilter {
	protected boolean keepHtmlTag = false;
	
	public HtmlTagFilter(Object obj) {
		keepHtmlTag = BooleanUtils.toBoolean(obj.toString());
	}

	public String filter(List<String> obj) {
		if(obj == null || obj.size() == 0)
			return "";
		
		return this.filter(obj.get(0));
	}
	
	public String filter(String obj) {
		if(StringUtil.isStringNull(obj))
			return "";
		
		String str = obj;
		if(keepHtmlTag)
			return str;
		return str.replaceAll("<.*?>", "");
	}
}
